package com.hllxd.hism.star.basic.service.model.rock;

import com.hllxd.hism.star.basic.service.collect.DateUtils;
import lombok.Data;

import java.util.Date;

/**
 * tbl_data_rock_yarn_quota 表
 * @author xiyong.lxy
 * @date 2020-11-1 20:37
 */
@Data
public class YarnQuotaEntity {
    public Long id;
    public String clusterName;
    public Integer queueType;
    public String queue;
    public String queueDesc;
    public Long cpuMin;
    public Long memMin;
    public Long cpuMax;
    public Long memMax;
    public Long cpuUsed;
    public Long memUsed;
    public Long cpuRate;
    public Long memRate;

    public String ownerID;
    public String ownerCn;
    public String departID;
    public Integer action;
    public String updateTime;
    public String createTime;

    public static YarnQuotaEntity build(String queue, Long cpuUsed, Long cpuMin, Long cpuMax, Long memUsed, Long memMin, Long memMax) {
        YarnQuotaEntity thiz = new YarnQuotaEntity();
        thiz.queue = queue;
        thiz.cpuUsed = cpuUsed;
        thiz.cpuMin = cpuMin;
        thiz.cpuMax = cpuMax;
        thiz.memUsed = memUsed;
        thiz.memMin = memMin;
        thiz.memMax = memMax;

        // 计算占用率
        thiz.cpuRate = (cpuUsed*10000)/cpuMin;
        thiz.memRate = (memUsed*10000)/memMin;

        thiz.createTime = DateUtils.formatDateTime(new Date());
        return thiz;
    }
}
